package hk.ust.cse.comp3111.studentSchedule;


import java.util.ArrayList;
import java.util.List;




import android.os.Bundle;
import android.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;


public class dbRegisterClassExample extends Fragment {
	
	RegisteredClassDatabaseHandler db_register;

public dbRegisterClassExample(){}
	
	@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
 
        View rootView = inflater.inflate(R.layout.db_register_example, container, false);
         
        return rootView;
    }
	
	
	
	@Override
	public void onStart() {
		super.onStart();

		db_register= new RegisteredClassDatabaseHandler(this.getActivity());
		
		List<String> details = new ArrayList<String>();
		//details = db_register.getAllRegisteredClass();
		ArrayList<String> listItems=new ArrayList<String>();
		
		for(String s : details){
        	listItems.add(s);
        }
		
		if(listItems.isEmpty()) listItems.add("Nothing");
		
		ListView myListView = (ListView) this.getView().findViewById(R.id.list_reg);
        
        ArrayAdapter<String> adapter;
        adapter=new ArrayAdapter<String>(this.getActivity(),android.R.layout.simple_list_item_1,listItems);
        
        myListView.setAdapter(adapter);
	
	
	}
	

	
	
	
	
	
	
	
	
	
	
	
	
	
	
}

